package greedy_algorithm.nowcoder.easy;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author Stark
 * @description 组队竞赛
 * 题目链接：https://www.nowcoder.com/questionTerminal/6736cc3ffd1444a4a0057dee89be789b?orderByHotValue=1&page=1&onlyReference=false
 * @date 2022/4/17 20:08
 **/
public class TeamCompetition {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            int n = scanner.nextInt();
            int[] arr = new int[3 * n];
            for (int i = 0; i < arr.length; i++) {
                arr[i] = scanner.nextInt();
            }
            Arrays.sort(arr);
            long sum = 0;
            //排序过后，数组0-n为最小的n个数,不需要参与运算
            //从n开始往后每两个数一组,
            //n和n+1,nums[n+1]>nums[n],nums[n]是一个一组的中位数
            //以此往后类推n+2和n+3;n+4和n+5
            for (int i = n; i < 3 * n; i += 2) {
                sum += arr[i];
            }
            System.out.println(sum);
        }
    }
}
